package com.hpeu_01.day0114;

import java.time.DayOfWeek;
import java.time.LocalDate;
import java.time.Month;

public class LocalDateDemo {
    public static void main(String[] args) {
        //now():根据当前时间创建对象，返回LocalDate对象
        LocalDate localDate = LocalDate.now();
        System.out.println(localDate);
        //of():静态方法，根据指定日期/时间创建对象
        LocalDate localDate1 = LocalDate.of(2021, 6, 21);
        System.out.println(localDate1);
        //getDayOfMonth():获得月份天数(1-31)
        int day = localDate.getDayOfMonth();
        System.out.println(day);
        //getDayOfYear():获得年份天数(1-366)
        int dayOfYear = localDate1.getDayOfYear();
        System.out.println(dayOfYear);
        //getDayOfWeek()获得星期几(返回一个 DayOfWeek 枚举值)
        DayOfWeek dayOfWeek = localDate.getDayOfWeek();
        System.out.println(dayOfWeek);
        String str= String.valueOf(dayOfWeek); //转换成String类型
        System.out.println(str.toLowerCase());// 转换成小写
        //getMonth()获得月份, 返回一个 Month 枚举值
        Month month = localDate.getMonth();
        System.out.println(month);
        //getMonthValue() 获得月份(1-12)
        int monthValue = localDate.getMonthValue();
        System.out.println(monthValue);
        // getYear()获得年份
        int year = localDate.getYear();
        System.out.println(year);


    }
}
